<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>C/C++ build system, I use xmake</title>
    <meta name="description" content="What is XMake?XMake is a modern C/C++ build system based on Lua.Its grammar is concise and easy to use, friendly to novices, even if you don’t know Lua at al...">

    
    <meta name="keywords" content="xmake,lua,C/C++,buildsystem,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/2021/05/03/please-use-xmake/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/cn?lang=0">
                    
                        <i class="fa fa-home"></i>中文
                    </a>
                </li>

                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>Projects
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/archive/">
                            
                        
                            <i class="fa fa-archive"></i>Archives
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/category/">
                            
                        
                            <i class="fa fa-th-list"></i>Categories
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/tag/">
                            
                        
                            <i class="fa fa-tags"></i>Tags
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/docs/">
                            
                        
                            <i class="fa fa-book"></i>Documents
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="https://xmake.io/#/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>Community
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/donation/">
                            
                        
                            <i class="fa fa-heart"></i>Donate
                        </a>
                    </li>
                    
                    
                    
                
                    
                     
                    
                
                    
                     
                     
                    <li>

                        
                            
                            <a href="/about/">
                            
                        
                            <i class="fa fa-user"></i>About
                        </a>
                    </li>
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                     
                     
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>C/C++ build system, I use xmake</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2021-05-03
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a-->
        <a href="/tag/#lua" title="Tag: lua" rel="tag">lua</a>&nbsp;
    
        <!--a href="/tag/#C%2FC%2B%2B" title="Tag: C/C++" rel="tag">C/C++</a-->
        <a href="/tag/#C/C++" title="Tag: C/C++" rel="tag">C/C++</a>&nbsp;
    
        <!--a href="/tag/#buildsystem" title="Tag: buildsystem" rel="tag">buildsystem</a-->
        <a href="/tag/#buildsystem" title="Tag: buildsystem" rel="tag">buildsystem</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <h3 id="what-is-xmake">What is XMake?</h3>

<p><a href="https://github.com/xmake-io/xmake">XMake</a> is a modern C/C++ build system based on Lua.</p>

<p>Its grammar is concise and easy to use, friendly to novices, even if you don’t know Lua at all, you can get started quickly, and it is completely free of any dependencies, lightweight, and cross-platform.</p>

<p>At the same time, it is also a self-satisfied build system with a powerful package management system and a fast build engine.</p>

<p>Compared with Ninja/Scons/Make as <code class="highlighter-rouge">Build backend</code>, CMake/Meson as <code class="highlighter-rouge">Project Generator</code>, and XMake not only provides <code class="highlighter-rouge">Build backend</code> and <code class="highlighter-rouge">Project Generator</code> at the same time, it also provides a built-in package manager.</p>

<div class="highlighter-rouge"><pre class="highlight"><code>xmake = Build backend + Project Generator + Package Manager
</code></pre>
</div>

<p>Therefore, you only need to install an XMake installation package that is less than 3M, and you don’t need to install other tools. You don’t even need to install make, and you don’t need to install heavyweight runtime environments such as Python and Java. You can quickly start your C/C++ development journey.</p>

<p>Maybe someone will say that the compiler always needs to be installed. This is not necessary, because XMake’s package management also supports automatically to pull remote compilation toolchains, such as llvm, Mingw, Android NDK or cross-compilation toolchain.</p>

<h3 id="why-do-xmake">Why do XMake</h3>

<p>Whenever discussing XMake with others in the Reddit community, everyone will always use the following picture to complain.</p>

<p><img src="https://imgs.xkcd.com/comics/standards.png" alt="" /></p>

<p>Although I was a little helpless and numb by the complaints, I still want to explain that the original intention of XMake was not to split the C/C++ ecology. On the contrary, XMake reuses the existing ecology as much as possible.</p>

<p>At the same time, it also allows users to have the same good experience as other languages when developing C/C++ projects, such as Rust/Cargo, Nodejs/Npm, Dlang/Dub, instead of looking for the third package everywhere, and studying how to transplant and compile. toss.</p>

<p>Therefore, if you don’t know XMake, please don’t draw conclusions too early, you can try it first, or take a moment to read the detailed introduction below.</p>

<h3 id="features-and-advantages-of-xmake">Features and advantages of XMake</h3>

<p>People often ask me what is special about XMake and what are the advantages compared to existing build tools such as CMake and Meson. Why should I use XMake instead of CMake?</p>

<p>Let me talk about the features and advantages first, XMake has the following points:</p>

<ul>
  <li>Concise and easy-to-learn configuration syntax, non-DSL</li>
  <li>Powerful package management, support semantic version, toolchain management</li>
  <li>Lightweight enough, no dependence</li>
  <li>Fast, the build speed is as fast as Ninja</li>
  <li>Simple and convenient multi-platform and toolchain switching</li>
  <li>Complete plugin system</li>
  <li>Flexible build rules</li>
</ul>

<p>XMake can be used as a supplement for those newcomers who want a simple and quick start to C/C++ development, or want more convenient and easy-to-use package management, or want to quickly write some short test projects temporarily.</p>

<p>XMake can help them improve development efficiency and make them pay more attention to the C/C++ project itself instead of spending more time on building tools and development environments.</p>

<p>Now, let us introduce these main features of XMake in detail.</p>

<h3 id="simple-syntax">Simple syntax</h3>

<p>CMake designs a DSL language for project configuration, which increases learning costs for users, and its grammatical readability is not very intuitive, it is easy to write overly complex configuration scripts, and also increases maintenance costs.</p>

<p>XMake reuses the existing well-known Lua language as its foundation, and provides a simpler and more straightforward configuration syntax.</p>

<p>Lua itself is a simple and lightweight language. There are only a few keywords and built-in types. Just read an article and you can basically get started. Compared with DSL, you can get a lot of relevant information more conveniently from the Internet.</p>

<h4 id="basic-syntax">Basic syntax</h4>

<p>However, some people still complain: don’t you still have to learn Lua?</p>

<p>In fact, it is not necessary. XMake adopts the method of separating the description field and the script field, so that in 80% of the cases, beginner users only need to configure the description field in a simpler and more direct way. It is completely unnecessary to configure it. As a Lua script, for example:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"test/*.c"</span><span class="p">,</span> <span class="s2">"example/**.cpp"</span><span class="p">)</span>
</code></pre>
</div>

<p>If because of the parentheses, it is still like a function call of a scripting language, then we can also write it like this (whether to bring the parentheses depends on personal preference, but I personally recommend the above method)</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span> <span class="s2">"test"</span>
    <span class="n">set_kind</span> <span class="s2">"binary"</span>
    <span class="n">add_files</span> <span class="s2">"src/*.c"</span>
    <span class="n">add_files</span> <span class="s2">"test/*.c"</span>
    <span class="n">add_files</span> <span class="s2">"example/**.cpp"</span>
</code></pre>
</div>

<p>We only need to know the common configuration interface, even if we don’t know Lua at all, we can quickly configure it.</p>

<p>We can compare the configuration of CMake:</p>

<div class="language-cmake highlighter-rouge"><pre class="highlight"><code><span class="nb">add_executable</span><span class="p">(</span>test <span class="s2">""</span><span class="p">)</span>
<span class="nb">file</span><span class="p">(</span>GLOB SRC_FILES <span class="s2">"src/*.c"</span><span class="p">)</span>
<span class="nb">file</span><span class="p">(</span>GLOB TEST_FILES <span class="s2">"test/*.c"</span><span class="p">)</span>
<span class="nb">file</span><span class="p">(</span>GLOB_RECURSE EXAMPLE_FILES <span class="s2">"example/*.cpp"</span><span class="p">)</span>
<span class="nf">target_sources</span><span class="p">(</span>test PRIVATE
    <span class="si">${</span><span class="nv">SRC_FILES</span><span class="si">}</span>
    <span class="si">${</span><span class="nv">TEST_FILES</span><span class="si">}</span>
    <span class="si">${</span><span class="nv">EXAMPLE_FILES</span><span class="si">}</span>
<span class="p">)</span>
</code></pre>
</div>

<p>Which is more intuitive and readable, at a glance.</p>

<h4 id="condition-configuration">Condition configuration</h4>

<p>If you have a preliminary understanding of some basic knowledge such as Lua, such as conditional judgments such as <code class="highlighter-rouge">if then</code>, then you can further configure some conditions.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/main.c"</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"macosx"</span><span class="p">,</span> <span class="s2">"linux"</span><span class="p">)</span> <span class="k">then</span>
        <span class="n">add_defines</span><span class="p">(</span><span class="s2">"TEST1"</span><span class="p">,</span> <span class="s2">"TEST2"</span><span class="p">)</span>
    <span class="k">end</span>
    <span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"windows"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">is_mode</span><span class="p">(</span><span class="s2">"release"</span><span class="p">)</span> <span class="k">then</span>
        <span class="n">add_cxflags</span><span class="p">(</span><span class="s2">"-Ox"</span><span class="p">,</span> <span class="s2">"-fp:fast"</span><span class="p">)</span>
    <span class="k">end</span>
</code></pre>
</div>

<p>Continue to compare the CMake version configuration:</p>

<div class="language-cmake highlighter-rouge"><pre class="highlight"><code><span class="nb">add_executable</span><span class="p">(</span>test <span class="s2">""</span><span class="p">)</span>
<span class="nb">if</span> <span class="p">(</span>APPLE OR LINUX<span class="p">)</span>
    <span class="nb">target_compile_definitions</span><span class="p">(</span>test PRIVATE TEST1 TEST2<span class="p">)</span>
<span class="nb">endif</span><span class="p">()</span>
<span class="nb">if</span> <span class="p">(</span>WIN32<span class="p">)</span>
    <span class="nb">target_compile_options</span><span class="p">(</span>test PRIVATE $&lt;$&lt;CONFIG:Release&gt;:-Ox -fp:fast&gt;<span class="p">)</span>
<span class="nb">endif</span><span class="p">()</span>
<span class="nf">target_sources</span><span class="p">(</span>test PRIVATE
    src/main.c
<span class="p">)</span>
</code></pre>
</div>

<h4 id="complex-script">Complex script</h4>

<p>If you have basically mastered xmake and are familiar with lua syntax and you want more flexible customized configuration, then XMake also provides more complete Lua script customization capabilities, and you can write any complex script.</p>

<p>For example, before building, do some preprocessing of all source files, after building, execute external gradle commands for later packaging, and even we can rewrite internal link rules to achieve deep custom compilation. We can use <a href="https: //xmake.io/#/zh/manual?id=import">import</a> interface, import the built-in linker extension module to realize complex and flexible linking process.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">before_build_file</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">,</span> <span class="n">sourcefile</span><span class="p">)</span>
        <span class="n">io</span><span class="p">.</span><span class="n">replace</span><span class="p">(</span><span class="n">sourcefile</span><span class="p">,</span> <span class="s2">"#define HAVE_XXX 1"</span><span class="p">,</span> <span class="s2">"#define HAVE_XXX 0"</span><span class="p">)</span>
    <span class="k">end</span><span class="p">)</span>
    <span class="n">on_link</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="n">import</span><span class="p">(</span><span class="s2">"core.tool.linker"</span><span class="p">)</span>
        <span class="n">linker</span><span class="p">.</span><span class="n">link</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">,</span> <span class="s2">"cc"</span><span class="p">,</span> <span class="n">target</span><span class="p">:</span><span class="n">objectfiles</span><span class="p">(),</span> <span class="n">target</span><span class="p">:</span><span class="n">targetfile</span><span class="p">(),</span> <span class="p">{</span><span class="n">target</span> <span class="o">=</span> <span class="n">target</span><span class="p">})</span>
    <span class="k">end</span><span class="p">)</span>
    <span class="n">after_build</span><span class="p">(</span><span class="k">function</span> <span class="p">(</span><span class="n">target</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">is_plat</span><span class="p">(</span><span class="s2">"android"</span> <span class="k">then</span>
            <span class="n">os</span><span class="p">.</span><span class="n">cd</span><span class="p">(</span><span class="s2">"android/app"</span><span class="p">)</span>
            <span class="n">os</span><span class="p">.</span><span class="n">exec</span><span class="p">(</span><span class="s2">"./gradlew app:assembleDebug"</span><span class="p">)</span>
        <span class="k">end</span>
    <span class="k">end</span><span class="p">)</span>
</code></pre>
</div>

<p>If you use CMake, you can also implement it in add_custom_command, but it seems that you can only simply execute some batch commands, and you can’t do all kinds of complex logic judgments, module loading, custom configuration scripts, and so on.</p>

<p>Of course, using cmake can certainly achieve the functions described above, but it is definitely not that simple.</p>

<p>If you are familiar with cmake, you can also try to help complete the following configuration:</p>

<div class="language-cmake highlighter-rouge"><pre class="highlight"><code><span class="nb">add_executable</span><span class="p">(</span>test <span class="s2">""</span><span class="p">)</span>
<span class="nb">file</span><span class="p">(</span>GLOB SRC_FILES <span class="s2">"src/*.c"</span><span class="p">)</span>
<span class="nb">add_custom_command</span><span class="p">(</span>TARGET test PRE_BUILD
    - TODO
    COMMAND echo hello
<span class="p">)</span>
<span class="nb">add_custom_command</span><span class="p">(</span>TARGET test POST_BUILD
    COMMAND cd android/app
    COMMAND ./gradlew app:assembleDebug
<span class="p">)</span>
- How can we override link stage?
<span class="nf">target_sources</span><span class="p">(</span>test PRIVATE
    <span class="si">${</span><span class="nv">SRC_FILES</span><span class="si">}</span>
<span class="p">)</span>
</code></pre>
</div>

<h3 id="powerful-package-management">Powerful package management</h3>

<p>As we all know, in the development of C/C++ related projects, the most important thing is the integration of various dependent packages, because there is no complete package management system like Rust/Cargo.</p>

<p>Therefore, every time we want to use a third-party library, we need to find and study the porting and compilation of various platforms, and we often encounter various compilation problems, which greatly delays the developer’s time and cannot concentrate on the actual The project is under development.</p>

<p>Finally, the current platform is done. If you change to another platform, you need to toss the dependency package again. In order to solve this problem, some third-party package managers, such as vcpkg/conan/conda, etc., have appeared, but some do not support semantic versions. , Some supported platforms are limited, but no matter what, it is a big step towards solving the dependency management of the C/C++ library.</p>

<p>However, with the package manager alone, it is still more troublesome to use them in C/C++ projects, because the corresponding build tools also need to be able to integrate and support them well.</p>

<h4 id="cmake-and-vcpkg">CMake and Vcpkg</h4>

<p>Let’s first look at the integrated support of CMake and Vcpkg:</p>

<div class="highlighter-rouge"><pre class="highlight"><code>cmake_minimum_required(VERSION 3.0)
project(test)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)
</code></pre>
</div>

<p>Disadvantages:</p>

<ul>
  <li>Additional configuration is required `-DCMAKE_TOOLCHAIN_FILE=<vcpkg_dir>/scripts/buildsystems/vcpkg.cmake</vcpkg_dir></li>
  <li>Does not support automatic installation of dependent packages, and requires the user to manually execute the <code class="highlighter-rouge">vcpkg install xxx</code> command to install</li>
  <li>The semantic version of vcpkg is not supported (it is said that the new version is supported)</li>
</ul>

<h4 id="cmake-and-conan">CMake and Conan</h4>

<div class="highlighter-rouge"><pre class="highlight"><code>```cmake
cmake_minimum_required(VERSION 2.8.12)
project(Hello)

add_definitions("-std=c++11")

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(hello hello.cpp)
target_link_libraries(hello gtest)
</code></pre>
</div>

<p>conanfile.txt</p>

<div class="language-text highlighter-rouge"><pre class="highlight"><code>[requires]
gtest/1.10.0

[generators]
cmake
</code></pre>
</div>

<p>Disadvantages:</p>

<ul>
  <li>Similarly, you still need to call <code class="highlighter-rouge">conan install ..</code> to install the package</li>
  <li>An additional conanfile.txt file needs to be configured to describe package dependency rules</li>
</ul>

<h4 id="meson-and-vcpkg">Meson and Vcpkg</h4>

<p>I didn’t find how to use the vcpkg package in Meson. I just found a related <a href="https://github.com/mesonbuild/meson/issues/3500">Issue #3500</a> discussion.</p>

<h4 id="meson-and-conan">Meson and Conan</h4>

<p>It seems that Meson has not yet supported Conan, but there is a solution in the official Conan document to support alignment, but it is very complicated. I didn’t see it. You can research it yourself: <a href="https://docs.conan.io/en/latest/reference/build_helpers/meson.html">https://docs.conan.io/en/ latest/reference/build_helpers/meson.html</a></p>

<h4 id="xmake-and-vcpkg">XMake and Vcpkg</h4>

<p>I have talked about so much before. The integration of other build tools and package management feels very troublesome to use, and different package managers have very different integration methods. Users want to quickly switch from Vcpkg to the Conan package, and the amount of change is very large. .</p>

<p>Next, let’s take a look at the packages provided by Vcpkg integrated in XMake:</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"vcpkg::zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"zlib"</span><span class="p">})</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<p>We only need to use the corresponding package name on the <code class="highlighter-rouge">add_requires</code> configuration and the <code class="highlighter-rouge">vcpkg::</code> ​​package namespace to directly integrate and use the zlib package provided by vcpkg.</p>

<p>Then, we only need to execute the xmake command to complete the entire compilation process, including the automatic installation of the zlib package, without the need to manually execute <code class="highlighter-rouge">vcpkg install zlib</code>.</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
note: try installing these packages <span class="o">(</span>pass -y to skip confirm<span class="o">)</span>?
<span class="gp">-&gt; </span>vcpkg::zlib
please input: y <span class="o">(</span>y/n<span class="o">)</span>

<span class="gp">=&gt; </span>install vcpkg::zlib .. ok
<span class="o">[</span>25%]: compiling.release src<span class="se">\m</span>ain.cpp
<span class="o">[</span>50%]: linking.release <span class="nb">test</span>
<span class="o">[</span>100%]: build ok!
</code></pre>
</div>

<h4 id="xmake-and-conan">XMake and Conan</h4>

<p>The next step is to integrate the Conan package, in exactly the same way, just change the package manager name.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"conan::zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">alias</span> <span class="o">=</span> <span class="s2">"zlib"</span><span class="p">})</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">)</span>
</code></pre>
</div>

<p>XMake will also automatically install the zlib package in conan, and then automatically integrate and compile.</p>

<h4 id="xmake-self-built-package-management">XMake self-built package management</h4>

<p>XMake and CMake have other build systems. The biggest difference, and one of the biggest advantages, is that it has a completely self-built package management system. We can not rely on vcpkg/conan at all, and can also quickly integrate dependent packages, such as :</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib 1.2.x"</span><span class="p">,</span> <span class="s2">"tbox &gt;= 1.6.0"</span><span class="p">)</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">add_packages</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="s2">"tbox"</span><span class="p">)</span>
</code></pre>
</div>

<p>Moreover, it also supports complete semantic version selection, multi-platform package integration, cross-compilation tool chain package integration, and even automatic pull and use of compilation tool chain packages.</p>

<p>Not only that, but we can also rely on self-built packages for customized configurations, such as:</p>

<h5 id="use-the-debug-version-to-depend-on-the-package">Use the debug version to depend on the package</h5>

<p>We can use the debug version library to implement breakpoint debugging of dependent libraries.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">debug</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<h5 id="set-msvc-runtime-library">Set msvc runtime library</h5>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">vs_runtime</span> <span class="o">=</span> <span class="s2">"MD"</span><span class="p">}})</span>
</code></pre>
</div>

<h5 id="use-dynamic-libraries">Use dynamic libraries</h5>

<p>The default integrated is static library, we can also switch to dynamic library.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">shared</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<h5 id="semantic-version-support">Semantic version support</h5>

<p>XMake’s self-built package integration supports complete version semantic specifications.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib 1.2.x"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib &gt;=1.2.10"</span><span class="p">)</span>
<span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib ~1.2.0"</span><span class="p">)</span>
</code></pre>
</div>

<h5 id="prohibit-the-use-of-system-libraries">Prohibit the use of system libraries</h5>

<p>By default, if the versions match, XMake will give priority to searching and using the libraries that the user has installed on the system. Of course, we can also forcibly prohibit the search and use of system libraries, and only download the installation package from the self-built package repository.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">system</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<h5 id="optional-dependency-package">Optional dependency package</h5>

<p>If the dependent package integration fails, XMake will automatically report an error, interrupt the compilation, and prompt the user: <code class="highlighter-rouge">zlib not found</code>, but we can also set it as optional package integration. In this way, even if the library is not installed successfully, it will not affect the compilation of the project. , Just skip this dependency.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"zlib"</span><span class="p">,</span> <span class="p">{</span><span class="n">optional</span> <span class="o">=</span> <span class="kc">true</span><span class="p">})</span>
</code></pre>
</div>

<h5 id="package-customization-configuration">Package customization configuration</h5>

<p>For example, the integration uses the boost library with the context/coroutine module configuration enabled.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"boost"</span><span class="p">,</span> <span class="p">{</span><span class="n">configs</span> <span class="o">=</span> <span class="p">{</span><span class="n">context</span> <span class="o">=</span> <span class="kc">true</span><span class="p">,</span> <span class="n">coroutine</span> <span class="o">=</span> <span class="kc">true</span><span class="p">}})</span>
</code></pre>
</div>

<h4 id="support-package-management-repository">Support package management repository</h4>

<p>In addition to supporting vcpkg/conan and self-built repository package integration support, XMake also supports other package management repositorys, such as Conda/Homebrew/Apt/Pacman/Clib/Dub, etc., and the integration method is exactly the same.</p>

<p>Users can quickly switch to use other repository packs without spending too much time studying how to integrate them.</p>

<p>Therefore, XMake does not destroy the C/C++ ecology, but greatly reuses the existing C/C++ ecology, and strives to improve the user experience of C/C++ dependent packages, improve development efficiency, and enable users to have more More time to focus on the project itself.</p>

<ul>
  <li>Official self-built repository <a href="https://github.com/xmake-io/xmake-repo">xmake-repo</a> (tbox &gt;1.6.1)</li>
  <li>Official package manager <a href="https://github.com/xmake-io/xrepo">Xrepo</a></li>
  <li><a href="https://xmake.io/#/zh-cn/package/remote_package?id=%e4%bd%bf%e7%94%a8%e8%87%aa%e5%bb %ba%e7%a7%81%e6%9c%89%e5%8c%85%e4%bb%93%e5%ba%93">User-built repository</a></li>
  <li>Conan (conan::openssl/1.1.1g)</li>
  <li>Conda (conda::libpng 1.3.67)</li>
  <li>Vcpkg (vcpkg:ffmpeg)</li>
  <li>Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)</li>
  <li>Pacman on archlinux/msys2 (pacman::libcurl)</li>
  <li>Apt on ubuntu/debian (apt::zlib1g-dev)</li>
  <li>Clib (clib::clibs/bytes@0.0.4)</li>
  <li>Dub (dub::log 0.4.3)</li>
</ul>

<h4 id="independent-package-management-command-xrepo">Independent package management command (Xrepo)</h4>

<p>In order to facilitate the package management in XMake’s self-built repository and the management and use of third-party packages, we also provide an independent Xrepo cli command tool to facilitate the management of our dependent packages</p>

<p>We can use this tool to quickly and easily complete the following management operations:</p>

<ul>
  <li>Installation package: <code class="highlighter-rouge">xrepo install zlib</code></li>
  <li>Uninstall the package: <code class="highlighter-rouge">xrepo remove zlib</code></li>
  <li>Get package information: <code class="highlighter-rouge">xrepo info zlib</code></li>
  <li>Get package compilation link flags: <code class="highlighter-rouge">xrepo fetch zlib</code></li>
  <li>Load package virtual shell environment: <code class="highlighter-rouge">xrepo env shell</code> (this is a very powerful feature)</li>
</ul>

<p>We can go to <a href="https://github.com/xmake-io/xrepo">Xrepo Project Homepage</a> to see more introduction and usage.</p>

<p><img src="https://xrepo.xmake.io/assets/img/xrepo.gif" alt="" /></p>

<h3 id="lightweight-and-no-dependencies">Lightweight and no dependencies</h3>

<p>To use Meson/Scons, you need to install python/pip first. To use Bazel, you need to install a runtime environment such as java. XMake does not need to install any additional dependent libraries and environments. Its own installation package is only 2-3M, which is very lightweight.</p>

<p>Although XMake is based on lua, thanks to the lightweight features of the lua glue language, xmake has fully built-in it, so installing XMake is equivalent to having a complete lua vm.</p>

<p>Some people will say that the compilation tool chain is always needed, not completely. On Windows, we provide a pre-compiled installation package, which can be downloaded and installed directly. The address is: <a href="https://github.com/ xmake-io/xmake/releases">Releases</a></p>

<p>In addition, XMake also supports remotely pulling the compilation toolchain, so even if your system environment has not installed any compiler, it doesn’t matter, users don’t have to worry about how to toss the compilation environment, only need to configure the tools needed in xmake.lua The chain is fine.</p>

<p>For example, if we use the mingw-w64 tool chain to compile C/C++ projects on Windows, we only need to do the following configuration.</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code><span class="n">add_requires</span><span class="p">(</span><span class="s2">"mingw-w64"</span><span class="p">)</span>
<span class="n">target</span><span class="p">(</span><span class="s2">"test"</span><span class="p">)</span>
    <span class="n">set_kind</span><span class="p">(</span><span class="s2">"binary"</span><span class="p">)</span>
    <span class="n">add_files</span><span class="p">(</span><span class="s2">"src/*.c"</span><span class="p">)</span>
    <span class="n">set_toolchains</span><span class="p">(</span><span class="s2">"mingw@mingw-w64"</span><span class="p">)</span>
</code></pre>
</div>

<p>After binding the mingw-w64 toolchain package through the <code class="highlighter-rouge">set_toolchains</code> configuration, XMake will automatically detect whether mingw-64 exists in the current system. If it has not been installed, it will automatically download and install, and then complete the project compilation. It can be done by executing the command <code class="highlighter-rouge">xmake</code>.</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
note: try installing these packages <span class="o">(</span>pass -y to skip confirm<span class="o">)</span>?
<span class="k">in </span>xmake-repo:
<span class="gp">-&gt; </span>mingw-w64 8.1.0 <span class="o">[</span>vs_runtime:MT]
please input: y <span class="o">(</span>y/n<span class="o">)</span>

<span class="gp">=&gt; </span>download https://jaist.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0 -release-posix-seh-rt_v6-rev0.7z .. ok
checking <span class="k">for </span>mingw directory ... C:<span class="se">\U</span>sers<span class="se">\r</span>uki<span class="se">\A</span>ppData<span class="se">\L</span>ocal<span class="se">\.</span>xmake<span class="se">\p</span>ackages<span class="se">\m\m</span>ingw-w64<span class="se">\8</span>.1.0<span class="se">\a</span>ad6257977e0449595004d7441358fc5
<span class="o">[</span>25%]: compiling.release src<span class="se">\m</span>ain.cpp
<span class="o">[</span>50%]: linking.release test.exe
<span class="o">[</span>100%]: build ok!
</code></pre>
</div>

<p>In addition to mingw-w64, we can also configure remote pull to use other tool chains, and even cross-compile tool chains, such as: llvm-mingw, llvm, tinycc, muslcc, gnu-rm, zig, etc.</p>

<p>If you want to learn more about the pull integration of the remote toolchain, you can read the document: <a href="https://xmake.io/#/zh-cn/package/remote_package?id=%e8 %87%aa%e5%8a%a8%e6%8b%89%e5%8f%96%e8%bf%9c%e7%a8%8b%e5%b7%a5%e5%e5%85%b7%e9%93 %be">Automatically pull the remote toolchain</a>.</p>

<h3 id="extremely-fast-parallel-compilation">Extremely fast parallel compilation</h3>

<p>Everyone knows that Ninja builds very fast, so many people like to use CMake/Meson to generate build.ninja, and then use Ninja to meet the needs of extremely fast builds.</p>

<p>Although Ninja is fast, we still need to generate build.ninja through the meson.build and CMakelist.txt files first. This generation process will take several seconds or even ten seconds.</p>

<p>And XMake not only has almost the same build speed as Ninja, but also does not need to generate additional build files. It has a built-in build system directly. In any case, only one <code class="highlighter-rouge">xmake</code> command can be used to achieve extremely fast compilation.</p>

<p>We have also done some comparative test data for your reference:</p>

<h4 id="multi-task-parallel-compilation-test">Multi-task parallel compilation test</h4>

<table>
  <thead>
    <tr>
      <th>Build System</th>
      <th>Termux (8core/-j12)</th>
      <th>Build System</th>
      <th>MacOS (8core/-j12)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>xmake</td>
      <td>24.890s</td>
      <td>xmake</td>
      <td>12.264s</td>
    </tr>
    <tr>
      <td>ninja</td>
      <td>25.682s</td>
      <td>ninja</td>
      <td>11.327s</td>
    </tr>
    <tr>
      <td>cmake(gen+make)</td>
      <td>5.416s+28.473s</td>
      <td>cmake(gen+make)</td>
      <td>1.203s+14.030s</td>
    </tr>
    <tr>
      <td>cmake(gen+ninja)</td>
      <td>4.458s+24.842s</td>
      <td>cmake(gen+ninja)</td>
      <td>0.988s+11.644s</td>
    </tr>
  </tbody>
</table>

<h4 id="single-task-compilation-test">Single task compilation test</h4>

<table>
  <thead>
    <tr>
      <th>Build System</th>
      <th>Termux (-j1)</th>
      <th>Build System</th>
      <th>MacOS (-j1)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>xmake</td>
      <td>1m57.707s</td>
      <td>xmake</td>
      <td>39.937s</td>
    </tr>
    <tr>
      <td>ninja</td>
      <td>1m52.845s</td>
      <td>ninja</td>
      <td>38.995s</td>
    </tr>
    <tr>
      <td>cmake(gen+make)</td>
      <td>5.416s+2m10.539s</td>
      <td>cmake(gen+make)</td>
      <td>1.203s+41.737s</td>
    </tr>
    <tr>
      <td>cmake(gen+ninja)</td>
      <td>4.458s+1m54.868s</td>
      <td>cmake(gen+ninja)</td>
      <td>0.988s+38.022s</td>
    </tr>
  </tbody>
</table>

<h3 id="fool-style-multi-platform-compilation">Fool-style multi-platform compilation</h3>

<p>Another feature of XMake is efficient and simple multi-platform compilation, whether you are compiling programs under windows/linux/macOS, compiling iphoneos/android or cross compiling.</p>

<p>Compilation configuration methods are similar, so users don’t need to go here to study how to compile under various platforms.</p>

<p><img src="https://xmake.io/assets/img/index/xmake-basic-render.gif" alt="" /></p>

<h4 id="compile-native-windowslinuxmacos-programs">Compile native Windows/Linux/MacOS programs</h4>

<p>The current native program compilation, we only need to execute:</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
</code></pre>
</div>

<h5 id="cmake">CMake</h5>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>mkdir build
<span class="gp">$ </span><span class="nb">cd </span>build
<span class="gp">$ </span>cmake --build ..
</code></pre>
</div>

<h4 id="compile-android-program">Compile Android program</h4>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -p android --ndk<span class="o">=</span>~/android-ndk-r21e
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h5 id="cmake-1">CMake</h5>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>mkdir build
<span class="gp">$ </span><span class="nb">cd </span>build
<span class="gp">$ </span>cmake -DCMAKE_TOOLCHAIN_FILE<span class="o">=</span>~/android-ndk-r21e/build/cmake/android.toolchain.cmake ..
<span class="gp">$ </span>make
</code></pre>
</div>

<h4 id="compile-ios-program">Compile iOS program</h4>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -p iphoneos
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h5 id="cmake-2">CMake</h5>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>mkdir build
<span class="gp">$ </span><span class="nb">cd </span>build
<span class="gp">$ </span>wget https://raw.githubusercontent.com/leetal/ios-cmake/master/ios.toolchain.cmake
<span class="gp">$ </span>cmake -DCMAKE_TOOLCHAIN_FILE<span class="o">=</span><span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>/ios.toolchain.cmake ..
<span class="gp">$ </span>make
</code></pre>
</div>

<p>I didn’t find a very convenient way to configure and compile the ios program. I could only find a third-party ios tool chain from other places to configure and compile.</p>

<h4 id="cross-compilation">Cross compilation</h4>

<p>We usually only need to set the root directory of the cross-compilation toolchain. XMake will automatically detect the toolchain structure and extract the compiler inside to participate in the compilation. No additional configuration is required.</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake f -p cross --sdk<span class="o">=</span>~/aarch64-linux-musl-cross
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h5 id="cmake-3">CMake</h5>

<p>We need to write an additional cross-toolchain.cmake configuration file first.</p>

<div class="language-cmake highlighter-rouge"><pre class="highlight"><code><span class="nb">set</span><span class="p">(</span>CMAKE_SYSTEM_NAME Linux<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_SYSTEM_PROCESSOR aarch64<span class="p">)</span>

<span class="nb">set</span><span class="p">(</span>TOOL_CHAIN_DIR ~/aarch64-linux-musl<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>TOOL_CHAIN_INCLUDE <span class="si">${</span><span class="nv">TOOL_CHAIN_DIR</span><span class="si">}</span>/aarch64-linux-musl/include<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>TOOL_CHAIN_LIB <span class="si">${</span><span class="nv">TOOL_CHAIN_DIR</span><span class="si">}</span>/aarch64-linux-musl/lib<span class="p">)</span>

<span class="nb">set</span><span class="p">(</span>CMAKE_C_COMPILER <span class="s2">"aarch64-linux-gcc"</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_CXX_COMPILER <span class="s2">"aarch64-linux-g++"</span><span class="p">)</span>

<span class="nb">set</span><span class="p">(</span>CMAKE_FIND_ROOT_PATH <span class="si">${</span><span class="nv">TOOL_CHAIN_DIR</span><span class="si">}</span>/aarch64-linux-musl<span class="p">)</span>

<span class="nb">set</span><span class="p">(</span>CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY<span class="p">)</span>

<span class="nb">include_directories</span><span class="p">(</span><span class="si">${</span><span class="nv">TOOL_CHAIN_DIR</span><span class="si">}</span>/aarch64-linux-musl/include<span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_INCLUDE_PATH <span class="si">${</span><span class="nv">TOOL_CHAIN_INCLUDE</span><span class="si">}</span><span class="p">)</span>
<span class="nb">set</span><span class="p">(</span>CMAKE_LIBRARY_PATH <span class="si">${</span><span class="nv">TOOL_CHAIN_LIB</span><span class="si">}</span><span class="p">)</span>
</code></pre>
</div>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>mkdir build
<span class="gp">$ </span><span class="nb">cd </span>build
<span class="gp">$ </span>cmake -DCMAKE_TOOLCHAIN_FILE<span class="o">=</span>../cross-toolchain.cmake ..
<span class="gp">$ </span>make
</code></pre>
</div>

<h3 id="conclusion">Conclusion</h3>

<p>If you are new to C/C++ development, you can use XMake to quickly get started with C/C++ compilation and construction.</p>

<p>If you want to develop and maintain a cross-platform C/C++ project, you can also consider using XMake to maintain the build, improve development efficiency, and let you focus more on the project itself, and no longer worry about tossing about transplanting dependent libraries.</p>

<p>Welcome to the XMake project:</p>

<ul>
  <li><a href="https://github.com/xmake-io/xmake/">Github project</a></li>
  <li><a href="https://xmake.io/#/">Project Homepage</a></li>
  <li><a href="https://github.com/xmake-io/xmake-repo">XMake Package Management Repository</a></li>
  <li>Community
    <ul>
      <li><a href="https://discord.gg/xmake">Discord chat room</a></li>
    </ul>
  </li>
</ul>


        </article>
        <hr>

        <!-- baidu ads -->
        

        
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
                    
                    <h2 id="chinese">中文</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/cn/2021/05/03/please-use-xmake/">C/C++ 构建系统，我用 xmake
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
        
            </ul>
        

        
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">Similar Posts</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/2021/12/17/xmake-update-v2.6.2/">Xmake v2.6.2 released, Support building Linux kernel driver module
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 released, Switch to Lua5.4 runtime, Support Rust and C++ mixed compilation
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 released, Improve C++20 Modules and support Nim, Keil MDK and Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 is released, Support Pascal/Swig program and Lua53 runtime
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 released, Use lockfile to freeze package dependencies and Vala/Metal language support
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        

        

        

        
        
        <p><strong>Prev Post</strong> <a href="/2021/04/08/xmake-update-v2.5.3/">xmake v2.5.3 Released, Support to build Linux bpf program and integrate Conda packages</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>Next Post</strong> <a href="/2021/05/15/xmake-update-v2.5.4/">xmake v2.5.4 Released, Support apt/portage package manager and improve xrepo shell</a></p>
        
    </div>
</div>


        <h2 id="comments">Comments</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,      
  language: 'en',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">


            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    Content
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#chinese">中文</a></li>
                    <li><a href="#similar_posts">Similar Posts</a></li>
                    <li><a href="#comments">Comments</a></li>
                </ul>
            </div>

            <!-- baidu ads -->
            

            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    Links
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

            <!-- chitika ads -->
            
        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
